<?php
    $likes = $this->getHelper('Likes');
    $api = $this->getHelper('Api');
    //$connect = Zend_Registry::get('connect');
    //$connect = 'on';
    $connect = $this->connect;
    if ($connect == 'off')
    {
        foreach ($this->alldata as $Key => $Val)
        {
            $images = explode(",", $Val['images']);
            ?><div class="product-grid ref">
                <div class="product-details" style="background:url('<?php echo PRODUCTS_PATH . "/" . $images[0]; ?>') no-repeat scroll center 30% rgba(0, 0, 0, 0);background-size:100% 100%;">
                    <p class="text-right">$<?php echo $Val['price']; ?></p>

                    <div class="product-desc">
                        <p class='product-title'><a href='<?php echo APPLICATION_URL ?>/product/index/product_id/<?php echo $Val['rkn_prod_id']; ?>'><?php echo $Val['prod_name']; ?></a></p>
                        <p class='category'><a href='#'><?php echo $Val['cat_name']; ?></a> | <a href='#'><?php echo $Val['sub_cat_name']; ?></a></p>
                    </div>
                </div>
                <div class="social-details">
                    <p class="pull-left">
                        <span class="like-counts"><?php echo $likes->getLikes($Val['rkn_prod_id']); ?> Likes</span>
                        <a href="<?php echo APPLICATION_URL ?>/ajax/like/product_id/<?php echo $Val['rkn_prod_id']; ?>" data-logged="<?php echo $likes->isLogged(); ?>" data-likable="<?php echo $likes->isLikable($Val['rkn_prod_id']); ?>" class="like-action"><?php echo!$likes->isLikable($Val['rkn_prod_id']) && $likes->isLogged() ? 'Unlike' : 'Like'; ?></a>
                    </p>
                    <div class="pull-right dropdown">
                        <a data-toggle="dropdown" href="#">Share</a>
                        <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
                            <li><a href="https://www.facebook.com/dialog/share?app_id=1425201874410100&display=popup&href=<?php echo APPLICATION_URL . '/product/detail/product_id/' . $Val['rkn_prod_id']; ?>&redirect_uri=<?php echo APPLICATION_URL; ?>">Facebook</a></li>
                            <li><a href="http://twitter.com/share?text=<?php echo urlencode($Val['prod_name']); ?>&url=<?php echo urlencode(APPLICATION_URL . '/product/detail/product_id/' . $Val['rkn_prod_id']); ?>&via=twitter&related=<?php echo urlencode($Val['cat_name']); ?>">Twitter</a></li>
                        </ul>
                    </div>
                    <p class="pull-right"></p>
                </div>
                <a class="btn btn-checkout-1 quick-view colorbox-href" href="<?php echo APPLICATION_URL ?>/product/detail/product_id/<?php echo $Val['rkn_prod_id']; ?>">QUICK VIEW</a>
            </div>

            <?php
        }
    }
    else
    {

        $data = $api->render($this->alldata);
        foreach ($data as $Key => $Val)
        {
            switch (@$Val['feed_social_type'])
            {
                case 'facebook':
                    ?>
                    <div class="product-grid facebook-block">
                        <div class="product-details">
                            <div class="upper-part"> 
                                <div class="logo">
                                    <img src="<?php echo IMAGES_PATH ?>/fb-api-logo.png">     
                                </div>
                                <div class="desc">
                                    <p class='social-title'><?php echo $data[0]['brand_name']; ?><span class="pull-right time-ago text-right"><?php echo getTimeAgo(strtotime($Val['feed_creation_time'])); ?></span></p>
                                    <p class="social-text"><?php $Val['feed_message']; ?></p>
                                </div>
                            </div>
                            <div class="lower-part">
                                <img src="<?php echo $Val['feed_image']; ?>" style="width:100%;max-width:100%;height:100%;">
                            </div>
                        </div>
                        <div class="social-details">
                            <ul style="" class="pull-left">
                                <li><?php echo $Val['feed_likes'] ?></li>
                                <li><img src="<?php echo IMAGES_URL ?>/thumbs-up.png"></li>
                                <li>2</li>
                                <li><img src="<?php echo IMAGES_URL ?>/comment-fb.png"></li>
                            </ul>
                            <ul class="pull-right">
                                <li><?php echo $Val['feed_shares']; ?></li>
                                <li>Shares</li>
                            </ul>
                        </div>
                    </div>
                    <?php
                    break;
                case 'twitter':
                    ?>
                    <div class="product-grid twitter-block">
                        <div class="product-details">
                            <div class="logo">
                                <img src="<?php echo IMAGES_PATH ?>/fb-api-logo.png">     
                            </div>
                            <div class="desc">
                                <p class='social-title'>@<?php echo $data[0]['brand_name']; ?><span class="pull-right time-ago"><?php echo getTimeAgo(strtotime($Val['feed_creation_time'])); ?></span></p>
                                <p class="social-text"><?php echo strlen(substr($Val['feed_message'], 0, 100)) == 100 ? substr($Val['feed_message'], 0, 100) . ".." : $Val['feed_message']; ?></p>
                            </div>
                        </div>
                        <div class="social-details">
                            <ul class="pull-left">
                                <li><?php echo $Val['feed_tweets']; ?></li>
                                <li>Retweets</li>
                            </ul>
                            <ul class="pull-right">
                                <li><img src="<?php echo IMAGES_URL ?>/twitter-reply-off.png" width="10" ></li>
                                <li><img src="<?php echo IMAGES_URL ?>/twitter-retweet-on.png" ></li>
                                <li><img src="<?php echo IMAGES_URL ?>/twitter-favourite-on.png" ></li>
                            </ul>
                        </div>
                    </div>

                    <?php
                    break;
                case 'instagram':
                    ?>
                    <div class="product-grid instagram-block">
                        <div class="product-details">
                            <div class="upper-part"> 
                                <div class="logo">
                                    <img src="<?php echo IMAGES_PATH ?>/instagram-api-logo.png">     
                                </div>
                                <div class="desc">
                                    <p class='social-title'><?php echo $data[0]['brand_name']; ?><span class="pull-right time-ago"><?php echo getTimeAgo(strtotime($Val['feed_creation_time'])); ?></span></p>

                                </div>
                            </div>
                            <div class="lower-part">
                                <img src="<?php echo $Val['feed_image']; ?>" style="width:100%;max-width:100%;height:100%;">
                            </div>
                        </div>
                        <div class="social-details">
                            <p class="pull-left">
                                <span class="like-counts">1 Likes</span>
                            </p>
                            <div class="pull-right">
                                <a data-toggle="dropdown" href="#">Share</a>
                            </div>
                        </div>

                    </div>
                    <?php
                    break;
                case 'youtube':
                    ?>
                    <div class="product-grid youtube-block">
                        <div class="product-details">
                            <div class="upper-part">
                                <div class="logo">
                                    <img src="<?php echo IMAGES_PATH ?>/youtube-logo.png">     
                                </div>
                                <div class="desc">
                                    <p class='social-title'>Youtube<span class="pull-right time-ago"><?php echo getTimeAgo(strtotime($Val['feed_creation_time'])); ?></span></p>
                                </div>
                            </div>
                            <div class="lower-part">
                                <img src="<?php echo $Val['feed_image']; ?>" style="width:100%;height:100%;">
                            </div>
                        </div>
                        <div class="social-details">
                            <p class="pull-left">
                                <span class="like-counts">1 Likes</span>
                            </p>
                            <div class="pull-right">
                                <a data-toggle="dropdown" href="#">Share</a>
                            </div>
                        </div>
                    </div>
                    <?php
                    break;
                default:
                    ?>
                    <div class="product-grid ref">
                        <div class="product-details" style="background:url('<?php echo PRODUCTS_PATH . "/" . $Val['images']; ?>') no-repeat scroll center 30% rgba(0, 0, 0, 0);background-size:100% 100%;">
                            <p class="text-right">$<?php echo $Val['price']; ?></p>

                            <div class="product-desc">
                                <p class='product-title'><a href='<?php echo APPLICATION_URL ?>/product/index/product_id/<?php echo $Val['rkn_prod_id']; ?>'><?php echo $Val['prod_name']; ?></a></p>
                                <p class='category'><a href='#'><?php echo $Val['cat_name']; ?></a> | <a href='#'><?php echo $Val['sub_cat_name']; ?></a></p>
                            </div>
                        </div>
                        <div class="social-details">
                            <p class="pull-left">
                                <span class="like-counts"><?php echo $likes->getLikes($Val['rkn_prod_id']); ?> Likes</span>
                                <a href="<?php echo APPLICATION_URL ?>/ajax/like/product_id/<?php echo $Val['rkn_prod_id']; ?>" data-logged="<?php echo $likes->isLogged(); ?>" data-likable="<?php echo $likes->isLikable($Val['rkn_prod_id']); ?>" class="like-action"><?php echo!$likes->isLikable($Val['rkn_prod_id']) && $likes->isLogged() ? 'Unlike' : 'Like'; ?></a>
                            </p>
                            <div class="pull-right dropdown">
                                <a data-toggle="dropdown" href="#">Share</a>
                                <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
                                    <li><a href="https://www.facebook.com/dialog/share?app_id=1425201874410100&display=popup&href=<?php echo APPLICATION_URL . '/product/detail/product_id/' . $Val['rkn_prod_id']; ?>&redirect_uri=<?php echo APPLICATION_URL; ?>">Facebook</a></li>
                                    <li><a href="http://twitter.com/share?text=<?php echo urlencode($Val['prod_name']); ?>&url=<?php echo urlencode(APPLICATION_URL . '/product/detail/product_id/' . $Val['rkn_prod_id']); ?>&via=twitter&related=<?php echo urlencode($Val['cat_name']); ?>">Twitter</a></li>
                                </ul>
                            </div>
                            <p class="pull-right"></p>
                        </div>
                        <a class="btn btn-checkout-1 quick-view colorbox-href" href="<?php echo APPLICATION_URL ?>/product/detail/product_id/<?php echo $Val['rkn_prod_id']; ?>">QUICK VIEW</a>
                    </div>

                    <?php
                    break;
            }
        }
    }
?>